package com.hps.demo.controller;

import com.hps.demo.msg.GoodTopicListener;
import com.hps.demo.msg.OrderTopicListener;
import com.hps.demo.msg.UserTopicListener;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author heps
 * @since 2020/11/23 15:17
 */
@RequestMapping("/topic/listener")
@RestController
public class TopicListenerController {

  @Resource
  private GoodTopicListener goodTopicListener;

  @Resource
  private UserTopicListener userTopicListener;

  @Resource
  private OrderTopicListener orderTopicListener;

  @GetMapping("/stop")
  public String stop() {
    goodTopicListener.setRunning(false);
    orderTopicListener.setRunning(false);
    userTopicListener.setRunning(false);
    return "success";
  }

  @GetMapping("/start")
  public String start() {
    goodTopicListener.startConsumer();
    orderTopicListener.startConsumer();
    userTopicListener.startConsumer();
    return "success";
  }
}
